package com.spgf.controller;

import java.util.Calendar;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

import com.spgf.controller.fragments.DespesasFragment;
import com.spgf.model.enums.Mes;
import com.spgf.model.utils.ConstantesSPGF;

public class DespesaMntSwipeActivity extends FragmentActivity {

	public static class SwipePadraoPagerAdapter extends FragmentStatePagerAdapter {

		public SwipePadraoPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public int getCount() {
			return 12;
		}

		@Override
		public Fragment getItem(int i) {

			Fragment fragment = new DespesasFragment();
			Bundle args = new Bundle();
			args.putInt(ConstantesSPGF.ARG_OBJECT, i);
			fragment.setArguments(args);
			return fragment;

		}

		@Override
		public CharSequence getPageTitle(int position) {
			return Mes.getEnum(position).getNome();
		}
	}

	ViewPager				mViewPager;

	SwipePadraoPagerAdapter	swipePagerAdapter;

	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.swipe_padrao);

		swipePagerAdapter = new SwipePadraoPagerAdapter(getSupportFragmentManager());

		final ActionBar actionBar = getActionBar();
		// actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.hide();

		mViewPager = (ViewPager) findViewById(R.id.pager);
		mViewPager.setAdapter(swipePagerAdapter);

		mViewPager.setCurrentItem(Calendar.getInstance().get(Calendar.MONTH));
	}
}
